
package com.netease.xone.widget.tabview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;

import com.netease.xone.R;

public class TabInfoDetailMenu extends AbsTabView {

    public TabInfoDetailMenu(Context context) {
        super(context);
        init();
    }

    public TabInfoDetailMenu(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        setBackgroundResource(R.drawable.toolbar_bg);
    }
    
    @Override
    public int getTabCount() {
        return 4;
    }

    @Override
    public int getTabDividerStyle() {
        return DIVIDER_NONE;
    }

    @Override
    public int getTabDividerResource() {
        return 0;
    }

    @Override
    public View getTabView(int index) {
        ImageView image = new ImageView(getContext());
        
        image.setClickable(true);
        if (index == 0) {
            image.setImageResource(R.drawable.icon_toolbar_comment_selector);
        } else if (index == 1) {
            image.setImageResource(R.drawable.icon_toolbar_trans_selector);
        } else if (index == 2) {
            image.setImageResource(R.drawable.icon_toolbar_like_selector);
        } else if (index == 3) {
            image.setImageResource(R.drawable.icon_toolbar_more_selector);
        }
        
        return image;
    }

    /**
     * 设置资讯正文底部菜单图片
     * @param index
     * @param resId
     */
    public void setImageResource(int index, int resId) {
        ((ImageView)mTabViews[index]).setImageResource(resId);
    }
   
    /**
     * 设置菜单是否可点击
     * @param flag
     */
    public void enableClick(boolean flag) {
        for (View view : mTabViews) {
            view.setClickable(flag);
        }
    }
}
